// dictman.d: Dictionary Manager
// Author: Wei Li (oldrev@gmail.com)
// License: GPL

module dayudict.dictman;

import std.file;

import dayudict.dict;

/**
  * DictionaryManager 负责管理和加载词库，属于 MVC 中的 M
  */
class DictionaryManager
{

	private IDictionary[] m_dicts;

	/**
	  * ctor, 加载所有的词库
	  */
	public this(char[] dictDir)
	{
		doLoadDicts(dictDir);	
	}


	private ~this()
	{
	}

	public IDictionary[] dictionaries()
	{
		return m_dicts;
	}
	
	private void doLoadDicts(char[] dictDir)
	{
		char[][] dicts = listdir(dictDir, "*.ddict");
		foreach(path; dicts)
		{
			m_dicts ~= new SqliteDictionary(path);
		}
	}
}
